<?php
Yii::app()->clientScript->registerCoreScript('jquery');
$script = "
$('#SiteUrl_status').click(function(){
    if (\$('#SiteUrl_status').attr('checked'))
        $('#SiteUrl_default').parents('.row').show();
    else
        $('#SiteUrl_default').attr('checked', false).parents('.row').hide();
});
if (\$('#SiteUrl_status').attr('checked'))
    $('#SiteUrl_default').parents('.row').show();
else
    $('#SiteUrl_default').parents('.row').hide();
";
Yii::app()->clientScript->registerScript(__CLASS__.'#SetDefault', $script, CClientScript::POS_READY);
if ($model->default) {
    $script = "\$('#SiteUrl_status').parents('.row').hide();\$('#SiteUrl_default').parents('.row').hide();";
    Yii::app()->clientScript->registerScript(__CLASS__.'#DisableChangeDefault', $script, CClientScript::POS_READY);
}
?>
<style type="text/css">
body {padding-bottom: 10px;}
div.wide form label {width: 120px;}
div.wide form .errorMessage {margin-left: 130px;}
div.wide form .buttons {margin-left: 130px;}
</style>
<div class="form wide">

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'site-url-form',
	'enableAjaxValidation'=>false,
)); ?>

    <?php if (! $model->IsNewRecord) echo $form->hiddenField($model, "id") ; ?>
    <?php echo $form->hiddenField($model,'site_id'); ?>

	<div class="row">
		<?php echo $form->labelEx($model,'url'); ?>
		<?php echo $form->textField($model,'url',array('size'=>60,'maxlength'=>100)); ?>
		<?php echo $form->error($model,'url'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'status', array('label'=>Yii::t('app', 'Active'))); ?>
		<?php echo $form->checkBox($model,'status'); ?>
		<?php echo $form->error($model,'status'); ?>
	</div>

	<div class="row" style="display: none;">
		<?php echo $form->labelEx($model,'default'); ?>
		<?php echo $form->checkBox($model,'default'); ?>
		<?php echo $form->error($model,'default'); ?>
	</div>

    <?php if ($model->isNewRecord == false):?>
    <div class="row">
        <?php echo $form->labelEx($model,'creation_datetime'); ?>
        <?php echo Yii::app()->getDateFormatter()->formatDateTime(strtotime($model->creation_datetime)); ?>
    </div>

    <div class="row">
        <?php echo $form->labelEx($model,'last_update'); ?>
        <?php echo Yii::app()->getDateFormatter()->formatDateTime(strtotime($model->last_update)); ?>
    </div>
    <?php endif;?>

	<div class="row buttons">
		<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
	</div>

<?php $this->endWidget(); ?>

</div><!-- form -->